package 泛型;


import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * Package Name:泛型
 * Description: 表示了泛型方法的使用
 * Date:2016/8/19 13:18
 * Copyright (c) 2016, zhongmu@suneee.com All Rights Reserved.
 */
public class Main {
    private static Log log = LogFactory.getLog(Main.class);
    public <T> T getObject(Class<T> c){
        T t = null;
        try {
            t = c.newInstance();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return t;
    }

    public static void main(String [] args){
        try {
            Main mainObj = new Main();
            Object obj = mainObj.getObject(Class.forName("泛型.Main"));
            log.info("创建对象成功");
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}
